package de.reondo.jos;

public final class ClassDependencyEdge {

	private Class<?> source;
	private Class<?> target;
	private ClassDependencyType type;
	private String occurrence;
	
	public String getOccurrence() {
		return occurrence;
	}

	public ClassDependencyType getType() {
		return type;
	}

	public ClassDependencyEdge() {
		this.type = ClassDependencyType.UNKNOWN;
		this.source = Object.class;
		this.target = Object.class;
	}
	
	public ClassDependencyEdge(ClassDependencyType dependencyType, Class<?> source, Class<?> target, String occurrence) {
		this.type = dependencyType;
		this.source = source;
		this.target = target;
		this.occurrence = occurrence;
	}

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((source == null) ? 0 : source.hashCode());
        result = prime * result + ((target == null) ? 0 : target.hashCode());
        result = prime * result + ((type == null) ? 0 : type.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        ClassDependencyEdge other = (ClassDependencyEdge) obj;
        if (source == null) {
            if (other.source != null)
                return false;
        } else if (!source.equals(other.source))
            return false;
        if (target == null) {
            if (other.target != null)
                return false;
        } else if (!target.equals(other.target))
            return false;
        if (type != other.type)
            return false;
        return true;
    }

	
}
